package com.user.query.pay.utils;

import com.user.query.controller.SystemComponent;
import com.wx.barcode.QRCodeUtil;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 二维码图片工具类
 * <p>Title: ImageUtils</p>
 * <p>Description:</p>
 * @author fan
 * @date 2016-9-1 下午5:59:34
 */
public class ImageUtils {
	
	/***
	 * 
	 * @param wxpath 微信扫码支付地址
	 * @return 二维码图片地址
	 * @throws Exception 
	 */
	public static String createWXImage(String wxpath,String fileName) throws Exception{
		String basePath = SystemComponent.getProperty("upload.imagePath");
		String imgPath = "/WX/"+path();
		QRCodeUtil.encode(wxpath, basePath+imgPath, fileName);
		return imgPath+"/"+fileName;
	}
	
	public static String path(){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
		return sdf.format(new Date());
	}
	
	public static void main(String[] args) {
	String s = 	path();
		System.out.println(s);
	}
}
